home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / source / libdump / libdump.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-24  |  1.4 KB  |  61 lines

  1.  
  2.  
  3.  
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include "svc.h"
  7. #include "ole.h"
  8.  
  9.  
  10. static void dumpsymboldictionary(LIBHDR *libheader, FILE *inlibfh);
  11.  
  12.  
  13.  
  14. main(int argc, char **argv)
  15. {
  16.   FILE *inlibfh;
  17.   LIBHDR libheader;
  18.   long modfilepos;
  19.  
  20.   if (argc != 2)
  21.      output(error, NOFILE, "Usage : %s file.lib\n", argv[0]);
  22.  
  23.   if ((inlibfh = fopen(argv[1], "rb")) == NULL)
  24.      output(error, NOFILE, "Couldn't open file %s\n", argv[1]);
  25.  
  26.   getlibheader(&libheader, inlibfh);
  27.   dumpsymboldictionary(&libheader, inlibfh);
  28.  
  29.   return 0;
  30. }
  31.  
  32.  
  33. static void dumpsymboldictionary(LIBHDR *libheader, FILE *inlibfh)
  34. {
  35.   int blockidx, bucketidx;
  36.   DICTENTRY dictentry;
  37.   char *modulename;
  38.   char *symbolp;
  39.  
  40.   for (blockidx = 0; blockidx < libheader->numdictblocks; blockidx++)
  41.      for (bucketidx = 0; bucketidx < NUMBUCKETS; bucketidx++)
  42.       {
  43.         dictentry = getsymdictentry(blockidx, bucketidx, libheader, inlibfh);
  44.         if (dictentry.isfound == FALSE)
  45.            continue;
  46.  
  47.         /* get the symbol name */
  48.         symbolp = makeasciiz(dictentry.symbolp);
  49.  
  50.         /* get the corresponding module name record (THEADR or COMENT) */
  51.         modulename = getmodulename(dictentry.modulefilepos, libheader, inlibfh);
  52.         printf("%s -- Module %s (%08lxh)\n", symbolp, modulename, dictentry.modulefilepos);
  53.         printf("Hash: Block %d, Bucket %d\n", blockidx, bucketidx);
  54.         free(symbolp);
  55.         free(modulename);
  56.       }
  57.  
  58.   return;
  59. }
  60.  
  61.